package com.issac.controller;

import com.issac.common.R;
import com.issac.entity.Accessory;
import com.issac.service.AccessoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName AccessoryController
 * @Author zy
 * @Date 2021/11/5 19:51
 * @Description AccessoryController
 * @Version 1.0
 */
@RestController
public class AccessoryController {

    @Autowired
    private AccessoryService service;

    // 通过水果id查询其附属品
    @GetMapping("/getAccessoryByFruitId")
    public R getAccessoryByFruitId(@RequestParam("fruitId") int id){
        return service.getAccessoryByFruitId(id);
    }

    // 新增附属品
    @PostMapping("/addAccessory")
    public R addAccessory(@RequestBody Accessory accessory){
        return service.addAccessory(accessory);
    }

    // 修改附属品信息
    @PostMapping("/updateAccessory")
    public R updateAccessory(@RequestBody Accessory accessory){
        return service.updateAccessory(accessory);
    }

    // 通过id删除附属品
    @PostMapping("/deleteAccessory")
    public R deleteAccessory(@RequestBody Accessory[] accessoryList){
        return service.deleteAccessory(accessoryList);
    }
}
